//
//  PreferenceController.m
//  weibo3
//
//  Created by Tian Wu on 11-4-25.
//  Copyright 2011年 nfsysu. All rights reserved.
//

#import "PreferenceController.h"


@implementation PreferenceController

- (id)init
{
    if (![super initWithWindowNibName:@"Preference"]) {
        return nil;
    }
    
    return self;
}

- (IBAction) changeAutoRefresh:(id) sender{
    if ([isAutoRefresh state] == NSOnState) {
        [[NSUserDefaults standardUserDefaults] setObject:@"ON" forKey:@"AutoRefresh"];
    }
    else{
        [[NSUserDefaults standardUserDefaults] setObject:@"OFF" forKey:@"AutoRefresh"];
    }
    
}

- (IBAction) changedisplayNotif:(id) sender{
    if ([displayNotif state] == NSOnState) {
        [[NSUserDefaults standardUserDefaults] setObject:@"ON" forKey:@"displayNotif"];
    }
    else{
        [[NSUserDefaults standardUserDefaults] setObject:@"OFF" forKey:@"displayNotif"];
    }
    
}

- (IBAction) changestatusNotif:(id) sender{
    if ([statusNotif state] == NSOnState) {
        [[NSUserDefaults standardUserDefaults] setObject:@"ON" forKey:@"statusNotif"];
    }
    else{
        [[NSUserDefaults standardUserDefaults] setObject:@"OFF" forKey:@"statusNotif"];
    }
    
}

- (IBAction) changecommentNotif:(id) sender{
    if ([commentNotif state] == NSOnState) {
        [[NSUserDefaults standardUserDefaults] setObject:@"ON" forKey:@"commentNotif"];
    }
    else{
        [[NSUserDefaults standardUserDefaults] setObject:@"OFF" forKey:@"commentNotif"];
    }
    
}

- (IBAction) changementionNotif:(id) sender{
    if ([mentionNotif state] == NSOnState) {
        [[NSUserDefaults standardUserDefaults] setObject:@"ON" forKey:@"mentionNotif"];
    }
    else{
        [[NSUserDefaults standardUserDefaults] setObject:@"OFF" forKey:@"mentionNotif"];
    }
    
}

- (IBAction) changedmNotif:(id) sender{
    if ([dmNotif state] == NSOnState) {
        [[NSUserDefaults standardUserDefaults] setObject:@"ON" forKey:@"dmNotif"];
    }
    else{
        [[NSUserDefaults standardUserDefaults] setObject:@"OFF" forKey:@"dmNotif"];
    }
    
}

- (IBAction) changefollowerNotif:(id) sender{
    if ([followerNotif state] == NSOnState) {
        [[NSUserDefaults standardUserDefaults] setObject:@"ON" forKey:@"followerNotif"];
    }
    else{
        [[NSUserDefaults standardUserDefaults] setObject:@"OFF" forKey:@"followerNotif"];
    }
    
}

- (void)dealloc
{
    [super dealloc];
}


- (void)windowDidLoad
{
    [super windowDidLoad];
    
    if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AutoRefresh"] isEqualToString:@"ON"]) {
        [isAutoRefresh setState:NSOnState];
    }
    else{
        [isAutoRefresh setState:NSOffState];
    }
    
    if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"displayNotif"] isEqualToString:@"ON"]) {
        [displayNotif setState:NSOnState];
    }
    else{
        [displayNotif setState:NSOffState];
    }
    
    if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"statusNotif"] isEqualToString:@"ON"]) {
        [statusNotif setState:NSOnState];
    }
    else{
        [statusNotif setState:NSOffState];
    }
    
    if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"commentNotif"] isEqualToString:@"ON"]) {
        [commentNotif setState:NSOnState];
    }
    else{
        [commentNotif setState:NSOffState];
    }
    
    if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"mentionNotif"] isEqualToString:@"ON"]) {
        [mentionNotif setState:NSOnState];
    }
    else{
        [mentionNotif setState:NSOffState];
    }
    
    if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"dmNotif"] isEqualToString:@"ON"]) {
        [dmNotif setState:NSOnState];
    }
    else{
        [dmNotif setState:NSOffState];
    }
    
    if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"followerNotif"] isEqualToString:@"ON"]) {
        [followerNotif setState:NSOnState];
    }
    else{
        [followerNotif setState:NSOffState];
    }

    
    // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
}

@end


